package com.ch02.ex33;

import java.util.concurrent.Phaser;

/**
 * Created by zc on 2016/2/15.
 */
public class Main {

    public static void main(String[] args){
        Phaser phaser = new Phaser(3);
        FileSearch system = new FileSearch("C:\\Windows", "log", phaser);
        FileSearch apps = new FileSearch("C:\\Program Files (x86)", "log", phaser);
        FileSearch documents = new FileSearch("C:\\Document And Settings", "log", phaser);

        Thread systemThread = new Thread(system, "system");
        systemThread.start();

        Thread appsThread = new Thread(apps, "Apps");
        appsThread.start();

        Thread documentThread = new Thread(documents, "Documents");
        documentThread.start();

        try {
            systemThread.join();
            appsThread.join();
            documentThread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("Terminated: " + phaser.isTerminated());
    }
}
